package com.dpiinc.TechPage.api;

import com.dpiinc.TechPage.model.BaseEntity;
import com.dpiinc.TechPage.model.EditNoteResult;
import com.dpiinc.TechPage.model.NoteListBean;
import com.dpiinc.TechPage.model.jbean.AuthenticateInfo;
import com.dpiinc.TechPage.model.jbean.BaseBean;
import com.dpiinc.TechPage.model.jbean.NoteLabelEditBean;
import com.dpiinc.TechPage.model.jbean.NoteLabelGetBean;
import com.dpiinc.TechPage.model.jbean.RecognizeApiKeyBean;
import com.dpiinc.TechPage.model.jbean.RecognizeGetBean;
import com.dpiinc.TechPage.model.jbean.RecognizeUploadBean;
import com.dpiinc.TechPage.model.jbean.StoreList;
import com.dpiinc.TechPage.oss.OssAuthCredentials;

import java.util.HashMap;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.QueryMap;

/**
 * @author hu489_000
 * @date 2018-07-05
 */
public interface RetrofitService {

    @FormUrlEncoded
    @POST("user/authenticate/")
    Observable<BaseEntity<AuthenticateInfo>> userAuthenticate(
            @Field("appId") String appId,
            @Field("name") String name,
            @Field("password") String password,
            @Field("platformInfo") String platformInfo,
            @Field("language") String language
    );

    @FormUrlEncoded
    @POST("user/third/authenticate/")
    Observable<BaseEntity<AuthenticateInfo>> userThirdAuthenticate(
            @Field("appId") String appId,
            @Field("thirdType") String thirdType,
            @Field("thirdUId") String thirdUId,
            @Field("thirdOtherId") String thirdOtherId,
            @Field("platformInfo") String platformInfo,
            @Field("language") String language
    );

    @FormUrlEncoded
    @POST("user/third/authenticate/")
    Observable<BaseEntity<AuthenticateInfo>> userThirdAuthenticate(
            @Field("appId") String appId,
            @Field("thirdType") String thirdType,
            @Field("thirdUId") String thirdUId
    );

    /**
     * 获取笔记列表
     *
     * @param map 请求参数
     *            uId           uId
     *            accessToken   accessToken
     *            number        一次默认拉取的条数，该值不传则是默认值20
     *            listType      0：普通笔记列表；1：包含指定内容的笔记列表；2：包含指定标签的笔记列表
     *            filterContent 筛选内容。listType为0时该字段无效；listType为1时，是文本内容；listType为2时是标签ID；
     *            page          请求第几页的记录
     *            latestGetTime 上次获取笔记列表的时间戳。listType为0时有效
     * @return NoteListBean
     */
    @GET("note/get/")
    Observable<BaseEntity<NoteListBean>> getNoteList(@QueryMap HashMap<String, String> map);

    /**
     * 编辑笔记（新增、修改、删除）
     *
     * @param map 请求参数
     *            uId
     *            accessToken
     *            noteOperate 0：新增；1：编辑；2：删除；
     *            noteId
     *            noteList 笔记id列表，批量删除时有效[noteId,noteId…]
     *            noteName
     *            createTime
     *            editTime
     *            labList 标签数组。Json格式[“labId”,”labId”..]
     * @return EditNoteResult
     */
    @FormUrlEncoded
    @POST("note/edit/")
    Observable<BaseEntity<EditNoteResult>> editNote(@FieldMap HashMap<String, String> map);

    /**
     * 清空笔迹
     * @param map
     * @return
     */
    @FormUrlEncoded
    @POST("note/clear/")
    Observable<BaseEntity<BaseBean>> clearNote(@FieldMap HashMap<String, String> map);

    /**
     * 获取阿里云Oss认证
     *
     * @param map 请求参数
     *            uId
     * @return
     *            accessToken
     */
    @GET("aliyun/oss/sts/")
    Observable<OssAuthCredentials> getOssAuthCredentials(@QueryMap HashMap<String, String> map);

    /**
     * 获取标签列表
     *
     * @param map 请求参数
     *            uId
     *            accessToken
     * @return
     */
    @GET("note/label/get/")
    Observable<BaseEntity<NoteLabelGetBean>> getLabelList(@QueryMap HashMap<String, String> map);


    @FormUrlEncoded
    @POST("note/label/edit/")
    Observable<BaseEntity<NoteLabelEditBean>> noteLabelEdit(@FieldMap HashMap<String, String> map);

    @FormUrlEncoded
    @POST("user/feedback/")
    Observable<BaseEntity<BaseBean>> feedBack(@FieldMap HashMap<String, String> map);


    @GET("note/recognize/get/")
    Observable<BaseEntity<RecognizeGetBean>> recognizeGet(@QueryMap HashMap<String, String> map);

    @FormUrlEncoded
    @POST("note/recognize/upload/")
    Observable<BaseEntity<RecognizeUploadBean>> recognizeUpload(@FieldMap HashMap<String, String> map);


    @GET("note/recognize/api/get/")
    Observable<BaseEntity<RecognizeApiKeyBean>> recognizeApiGet(@QueryMap HashMap<String, String> map);

    @GET("user/getShop/")
    Observable<BaseEntity<StoreList>> getGoodsList(@QueryMap HashMap<String, String> map);

    @GET("user/getInternationShop/")
    Observable<BaseEntity<StoreList>> getAbroadGoodsList(@QueryMap HashMap<String, String> map);
}
